/*
 * Copyright 2011 Marcos Fabio Pereira
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.moveme.network.payload.state;

import java.nio.ByteBuffer;

import com.moveme.utils.Float4;

/**
 * Move gem state
 * 
 * @author Marcos Fabio Pereira
 *
 */
public class PSMoveGemState {

    public final Float4 pos;
    
    public final Float4 vel;
    
    public final Float4 accel;
    
    public final Float4 quat;
    
    public final Float4 angvel;
    
    public final Float4 angaccel;
    
    public final Float4 handlePos;
    
    public final Float4 handleVel;
    
    public final Float4 handleAccel;
    
    public final PSMovePadData pad; // 4 bytes
    
    public final long timestamp;
    
    public final float temperature;
    
    public final float cameraPitchAngle;
    
    public final int trackingFlags;
    
    public PSMoveGemState(ByteBuffer byteBuffer, int idMoveController) {
        int offset = 104 + idMoveController * 176;
        pos = new Float4(byteBuffer, offset);
        vel = new Float4(byteBuffer, offset + 16);
        accel = new Float4(byteBuffer, offset + 32);
        quat = new Float4(byteBuffer, offset + 48);
        angvel = new Float4(byteBuffer, offset + 64);
        angaccel = new Float4(byteBuffer, offset + 80);
        handlePos = new Float4(byteBuffer, offset + 96);
        handleVel = new Float4(byteBuffer, offset + 112);
        handleAccel = new Float4(byteBuffer, offset + 128);
        pad = new PSMovePadData(byteBuffer, idMoveController);
        timestamp = byteBuffer.getLong(offset + 152);
        temperature = byteBuffer.getFloat(offset + 160);
        cameraPitchAngle = byteBuffer.getFloat(offset + 164);
        trackingFlags = byteBuffer.getInt(offset + 168);   
    }
    
}
